package com.easy;

import sun.reflect.generics.tree.Tree;

/**
 * Created by Lxk on 2019/5/12.
 */
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode(int x) { val = x; }
}

public class Solution226 {

    void reverseTree(TreeNode curNode){
        if(curNode == null){
            return ;
        }
        TreeNode temp = curNode.left;
        curNode.left = curNode.right;
        curNode.right = temp;
        reverseTree(curNode.left);
        reverseTree(curNode.right);
    }

    public TreeNode invertTree(TreeNode root) {
        reverseTree(root);
        return root;
    }

}
